package com.hm.common.def;

import java.util.HashMap;
import java.util.Map;

import com.hm.common.su.EnumsSuport;
import com.hm.common.util.StringUtil;

/**
 * @author shishun.wang
 * @date 下午5:32:02 2017年9月19日
 * @version 1.0
 * @describe
 */
public enum WhetherEnum implements EnumsSuport {

	YES("YES", "是"),

	NO("NO", "否");

	private String code;

	private String desc;
	
	private WhetherEnum() {}

	private WhetherEnum(String code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public String desc() {
		return this.desc;
	}

	public String code() {
		return this.code;
	}

	public static WhetherEnum conversion(String code) {
		if (StringUtil.isBlankOrNull(code)) {
			return null;
		}
		for (WhetherEnum enumTmp : WhetherEnum.values()) {
			if (enumTmp.code.equals(code)) {
				return enumTmp;
			}
		}
		return null;
	}
	
	public Map<String, String> enumValues() {
		Map<String, String> vo = new HashMap<String, String>();
		for (WhetherEnum statusDef : WhetherEnum.values()) {
			vo.put(statusDef.code, statusDef.desc);
		}

		return vo;
	}
}
